package logic

import (
	"context"
	"zg2/zk1_user/userRpc/models"

	"zg2/zk1_user/userRpc/internal/svc"
	"zg2/zk1_user/userRpc/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShowUserLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShowUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowUserLogic {
	return &ShowUserLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ShowUserLogic) ShowUser(in *user.ShowUserRequest) (*user.ShowUserResponse, error) {
	// todo: add your logic here and delete this line

	userIdentity := models.UserIdentity{}
	models.DB.Where("id=?", in.Id).Find(&userIdentity)
	return &user.ShowUserResponse{
		Id:       int64(userIdentity.ID),
		RealName: userIdentity.RealName,
		IdCard:   userIdentity.IdCard,
		Status:   userIdentity.Status,
	}, nil
}
